package cn.zzm.replyTo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

/**
 * springboot自动装配JMS的写法
 * Request-Response模式
 */
@Service
public class ProducerR {

    @Autowired
    private JmsTemplate jmsTemplate;

    public void sendMessage(String destination, final String message){
        jmsTemplate.setPubSubDomain(false);
        jmsTemplate.convertAndSend(destination, message);

    }

    @JmsListener(destination = "replyTo.queue")
    public void consumerMessage(String text){
        System.out.println("从replyTo.queue收到报文"+text);
    }

}
